﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Compose;

namespace ConsoleApplication1
{
    //[Export(typeof(ICommand))]
    //[ExportMetadata("CommandName", "load")]
    //class Class3 : ICommand
    //{
    //    public string Execute(string input)
    //    {
    //        Program.db.Commands.AddRange(Program.HotRepair<Parts<ICommand, ICommandMedaData>>(input).Commands);
    //        return "从" + input + "加载了新的插件";
    //    }

    //    void IDisposable.Dispose()
    //    {
    //        throw new NotImplementedException();
    //    }

    //}

    [CommandLine.Command(CommandName = "load")]
    public class Class3 : CmdLine
    {

        public override string Execute(string input)
        {
            try
            {
                Program.db.Commands.AddRange(Program.HotRepair<Parts<CmdLine, ICommandMedaData>>(input).Commands);
                return "从" + input + "加载了新的插件";
            }
            catch (Exception ex)
            {

                return ex.Message;
            }

        }

        public Class3() : base("load")
        {
        }

        public override void CallBack(string msg)
        {

            Console.WriteLine(mName + ":" + msg);
        }



        public override string ReceiveMsg(string msg)
        {
            Console.WriteLine(mName + ":" + msg);
            return null;
        }

        public override void Dispose()
        {
            base.Dispose();
        }
    }
}
